package hzau.controller;

import hzau.pojo.College;
import hzau.pojo.requestParams.CollegeRegisterParam;
import hzau.result.Result;
import hzau.service.CollegeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
@CrossOrigin
@RestController
@RequestMapping("college")
@Api(tags = "学院相关接口")
public class CollegeController {
    @Autowired
    CollegeService collegeService;
    @PostMapping("register")
    @ApiOperation("新增学院")
    public Result register(@RequestBody CollegeRegisterParam college){
        return collegeService.register(college);
    }
    @DeleteMapping("delete")
    @ApiOperation("学院删除")
    public Result delete(Long id){return collegeService.delete(id);}
    @GetMapping("getOne/{universityId}/{collegeId}")
    @ApiOperation("查询一个学院")
    public Result getOne(@PathVariable Long universityId,@PathVariable Long collegeId){
        return collegeService.getOne(universityId,collegeId);
    }
    @GetMapping("getAll/{universityId}/{page}")
    @ApiOperation("查询一个学校的所有学院")
    public Result getPage(@PathVariable Long universityId,@PathVariable Integer page){
        return collegeService.getAll(universityId,page);
    }
    @GetMapping("getAllCollege/{universityId}")
    @ApiOperation("查询一个学校的所有学院")
    public Result getAllCollege(@PathVariable Long universityId){
        return collegeService.getAllCollege(universityId);
    }
    @PostMapping("update")
    @ApiOperation("更新学院信息")
    public Result update(@RequestBody College college){
        return collegeService.update(college);
    }
    @GetMapping("getPresident/{collegeId}")
    @ApiOperation("获取院长信息")
    public Result getPresident(@PathVariable  Long collegeId){
        return collegeService.getPresident(collegeId);
    }
    @PostMapping("setPresident")
    @ApiOperation("获取院长信息")
    public Result setPresident( Long collegeId,Long id){
        return collegeService.setPresident(collegeId,id);
    }

}
